import { request } from '#/api/request';

/**
 * 获取示例表格数据
 */
export async function getTenderList(params: Api.PageFetchParams) {
  return request.Get('/tenders', { params });
}

interface ImportFormData {
  file?: File;
  file_id?: number;
}
export async function importTender(data: ImportFormData) {
  return request.Post('/tenders/import', data);
}

export async function createTender(data: any) {
  return request.Post('/tenders', data);
}

export async function updateTender(id: number, data: any) {
  return request.Post(`/tenders/${id}`, data);
}

export async function deleteTender(id: number) {
  return request.Delete(`/tenders/${id}`);
}

export async function getTenderTypes() {
  return request.Get('/tender_types', {
    cacheFor: {
      mode: 'restore',
      expire: 30 * 60 * 1000,
    },
  });
}

export async function getTags(type: string = 'all') {
  return request.Get(`/tags/${type}`, {
    cacheFor: {
      mode: 'restore',
      expire: 10 * 60 * 1000,
    },
  });
}
